/*
 * 百度在线网络技术（北京）有限公司拥有本软件版权2022并保留所有权利。
 * Copyright 2022, Baidu.com,Inc 2:Baidu Online Network Technology (Beijing) Co.,Ltd,
 * All rights reserved.
 */

package com.azdebugit.suanfa.test.niu;

import java.util.*;
public class MainIP{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(sc.hasNext()){
            String ip = sc.nextLine();
            long ipDeci = Long.parseLong(sc.nextLine());
            System.out.println(transferToIpDecimal(ip));
            System.out.println(transferToIpAddress(ipDeci));
        }
    }
    // ip转成10进制数
    public static long transferToIpDecimal(String ip) {
        String[] ips = ip.split("\\.");
        long res = 0;
        for (int i = ips.length - 1, n = 0; i >= 0; i--) {
            res += Integer.parseInt(ips[i]) * Math.pow(2, n);
                n += 8;
            }
        return res;
    }
    // 10进制数转成ip
    public static String transferToIpAddress(long ipDeci) {
        StringBuilder sb = new StringBuilder();
        long ipi = 0;
        while (ipDeci > 0) {
            ipi = ipDeci % (long) Math.pow(2, 8);
            ipDeci = ipDeci / (long) Math.pow(2, 8);
            if (sb.length() == 0) {
                sb = sb.append(ipi);
            } else {
                sb = new StringBuilder().append(ipi).append(".").append(sb);
            }
        }
        return sb.toString();
    }
}
